package org.ym.file.domain.model.rule.enums;

import org.ym.file.domain.model.rule.enums.RuleType;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 * @author ym
 */
@Converter
public class RuleTypeConverter implements AttributeConverter<RuleType,Integer> {
    @Override
    public Integer convertToDatabaseColumn(RuleType attribute) {
        return attribute.getCode();
    }

    @Override
    public RuleType convertToEntityAttribute(Integer dbData) {
        return RuleType.getRuleType(dbData);
    }
}
